//
// loi.cpp for 202loi in /home/morel_t//Rendu/maths/202loi
// 
// Made by thomas morel
// Login   <morel_t@epitech.net>
// 
// Started on  Fri Mar  9 14:53:08 2012 thomas morel
// Last update Fri Mar  9 15:49:51 2012 thomas morel
//

#include "202loi.h"
#include "Table.hh"

double		loi_conjointe(int x, int y)
{
  double	result = 0;

  result = (6 - x);
  result *= (7 - y);
  result /= 300;
  return (result);
}

double		loi_marginale_y(std::string **tab, int y)
{
  int		x = 1;
  double	result = 0;

  while (x <= 5)
    {
      result += toDouble(tab[y][x]);
      x++;
    }
  return (result);
}

double		loi_marginale_x(std::string **tab, int x)
{
  int		y = 1;
  double	result = 0;

  while (y <= 5)
    {
      result += toDouble(tab[y][x]);
      y++;
    }
  return (result);
}

double		esperance_x(std::string **tab)
{
  double	result = 0;

  for (int x = 1; x <= 5; x++)
    result += (toDouble(tab[6][x]) * x);
  return (result);
}

double		esperance_y(std::string **tab)
{
  double	result = 0;

  for (int y = 1; y <= 5; y++)
    result += (toDouble(tab[y][6]) * y);
  return (result);
}
